import 'package:demo_proj01/pages/homepage.dart';
import 'package:demo_proj01/pages/tab_page.dart';
import 'package:demo_proj01/pages/webviewpage.dart';
import 'package:flutter/material.dart';

class Routes {
  static Route<dynamic> generateRoute(RouteSettings settings) {
    switch (settings.name) {
      case RoutePath.tab:
        return pageRoute(TabPage());
      case RoutePath.webViewPage:
        return pageRoute(WebViewPage(title: "跳转来的页面"));
    }
    return pageRoute(
      Scaffold(
        body: SafeArea(child: Center(child: Text("路由${settings.name}找不到"))),
      ),
    );
  }

  static MaterialPageRoute pageRoute(
    Widget page, {
    RouteSettings? settings,
    bool? fullscreenDialog,
  }) {
    return MaterialPageRoute(
      builder: (context) => page,
      settings: settings,
      fullscreenDialog: fullscreenDialog ?? false,
    );
  }
}

class RoutePath {
  static const String tab = "/";
  static const String webViewPage = "/webViewPage";
}
